﻿var me = this,
    column = view.ownerCt.getColumnManager().getHeaderAtIndex(cellIndex);

if (column.dataIndex == 'JAWBS' || column.dataIndex == 'LRWBS') {//被联动的列
    //弹出窗
    var window1 = Ext.create('Ext.window.Window', {
        title: 'WBS',
        height: 520,
        width: 600,
        modal: true,
        // closeAction: 'hide',
        // layout: 'float',
        layout: {
            type: 'float',
            columns: 1
        },
        buttons: [{
            xtype: "button",
            text: "Confirm",
            handler: function () {
                var win = this.up("window"),
                    refs = win.getReferences();
                //赋值 

                var selectRecord = refs.grid.getSelection();
                if (selectRecord.length > 0) {

                    record.data[column.dataIndex] = selectRecord[0].get("code");
                    record.commit();
                }
                win.close();
            }
        }, {
            xtype: "button",
            text: "Cancel",
            handler: function () {
                this.up("window").close();
            }
        }],
        //主视图内部控件
        referenceHolder: true,
        items: [{
            xtype: 'paigrid',
            reference: 'grid',
            flex: 10,
            enableAdd: false,
            enableDel: false,
            pagingConfigs: {
                displayInfo: true
            },
            enablePaging: true,
            enableSearch: false,

            columns: [{
                text: 'code',
                dataIndex: 'code',
                flex: 3
            }, {
                text: 'name',
                dataIndex: 'name',
                flex: 3
            }],
            store: {
                autoLoad: true,
                pageSize: 10,
                fields: ['code', 'name'],
                proxy: {
                    type: 'pai.rest',
                    url: 'jlr-rest/api/queryDictItemObj',
                    ns: PAI.application.serviceUrl,
                    postRead: true,
                    timeout: 100000000,
                    extraParams: {
                        "name": "WBS"
                    },
                    reader: {
                        rootProperty: 'dictItemObjList'
                    }
                }
            },
            listeners: {
                itemdblclick: function (grid, r) {
                    record.data[column.dataIndex] = r.get('code');
                    record.commit();
                    window1.close();
                }
            }
        }],
        listeners: {
            close: function () {
                Ext.getBody().unmask();
            }
        }
    }).show();
}